package com.jiawa.train.batch.job;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.log.Log;
import com.jiawa.train.batch.feign.BusinessFeign;
import com.jiawa.train.common.resp.CommonResp;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

@DisallowConcurrentExecution
public class DailyTrainJob implements Job {

    @Autowired
    private BusinessFeign businessFeign;

    public void execute(JobExecutionContext context) throws JobExecutionException {
        Date date = new Date();
        DateTime dateTime = DateUtil.offsetDay(date, 4);
        Date jdkDate = dateTime.toJdkDate();
        CommonResp<Object> commonResp = businessFeign.genDaily(jdkDate);
        System.out.println("每日车次数据的结果为："+commonResp);
    }
}
